<%-- 
    Document   : attendanceTable
    Created on : 2019-7-26, 8:02:09
    Author     : dusin
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
        <link rel="stylesheet" href="../../js/jquery/themes/default/easyui.css" type="text/css" />
        <link rel="stylesheet" href="../../js/jquery/themes/icon.css" type="text/css" />
        <link rel="stylesheet" href="../../js/jquery/themes/color.css" type="text/css" />
        <link rel="stylesheet" href="../../css/demo.css" type="text/css" />
        <script type="text/javascript" src="../../js/jquery/jquery.min.js"></script>
        <script type="text/javascript" src="../../js/jquery/jquery.easyui.min.js"></script>
        <script type="text/javascript">
            $(document).ready(function() {
                var columns = [ {field:"no", width:"50",title:'序号'},
                                {field:"studentno", width:"100",title:'学号'},
                                {field: "name" ,width:"150",title:'姓名'}];
                var detail=[1,2,3,5,6,8];
                for(var i=1;i<detail.length+1;i++){
                    var r = {field:'no'+i,width:"50",title:i,formatter:formatterAttendanceStatus,
                        editor:{
                            type:'combobox',
                            options:{
                                valueField:'id',
                                textField:'name',
                                method:'get',
                                url:'../data/attendancetype.json',
                                required:true
                            }
                        }  
                    }
                    columns.push(r);
                }
                $('#dgAttendanceTable').datagrid({
                    url:'../../servlet/teacher/GetAttendanceTable',
                    columns:[columns],
                    fitColumns:true,                    
                    height:($(window).height()-40)+'px',
                    title:'${courseName}'+'->考勤表'  ,
                    singleSelect:true,
                    queryParams:{attendanceId:attendanceId},
                });
            });
        </script>
    </head>
    <body>       
        <table id="dgAttendanceTable"></table>
        <script type="text/javascript">
            var teachclassid = '<%=session.getAttribute("teachclassid")%>'
            var courseName = '<%=session.getAttribute("courseName")%>'
            var attendanceId = '<%=request.getParameter("attendanceId")%>';
            function formatterAttendanceStatus(value, row){
                if(value==1){   //这里value的类型是String，不能用‘===’三等号
                    return '<span style="color:red;">'+'✖'+'</span>';
                }else if(value==2){
                    return '<span style="color:blue;font-size:30px">'+'△'+'</span>';
                }else if(value==3){
                    return '<span style="color:blue;">'+'◯'+'</span>';
                }else if(value==4){
                    return '<span style="color:yellow;">'+'L'+'</span>';
                }else if(value==5){
                    return '<span style="color:yellow;">'+'E'+'</span>';
                }else{
                   return '<span style="color:green;">'+'✔'+'</span>';
                }                
            }
        </script>
    </body>
</html>
